package com.hencoder.hencoderpracticedraw1.practice;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

public class Practice11PieChartView extends View {

    public Practice11PieChartView(Context context) {
        super(context);
    }

    public Practice11PieChartView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public Practice11PieChartView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

//        综合练习
//        练习内容：使用各种 Canvas.drawXXX() 方法画饼图
        Paint paint = new Paint();
        Path path = new Path();
        paint.setStyle(Paint.Style.FILL);
        RectF rectF = new RectF();
        //200, 100, 800, 500, -110, 100, true, paint
        paint.setColor(Color.RED);
        rectF.left = 50;
        rectF.top = 50;
        rectF.right = 300;
        rectF.bottom = 300;
        canvas.drawArc(rectF, 180, 110, true, paint);
//        paint.setColor(Color.BLACK);
//        canvas.drawRect(rectF,paint);
        rectF.left = 60;
        rectF.top = 60;
        rectF.right = 320;
        rectF.bottom = 320;
        paint.setColor(Color.BLUE);
        canvas.drawArc(rectF, 300, 60, true, paint);


        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(Color.YELLOW);
       canvas.drawLine(100,100,50,50,paint);
    }
}
